package xpn.platform.modules.workflow.other.comment;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;

import java.util.List;

@RepositoryRestResource(path = "workflow_comment")
public interface CommentDAO extends JpaRepository<Comment, Long> {
    @RestResource(path = "findByInstanceId")
    List<Comment> findByInstanceId(@Param("id") Long id);

    @Query("select c from Comment c where c.userId=:userId and c.instance.id=:instanceId and c.todo.id=:todoId and c.column.id=:columnId")
    Comment findByUserAndInstanceAndTodoAndColumn(@Param("userId") String userId, @Param("instanceId") Long instanceId, @Param("todoId") Long todoId, @Param("columnId") Long columnId);
}
